package com.andnnl.hanoi;

/**
 * 汉诺塔
 * Created by chenss on 2020/3/17.
 */
public class HanoiTest {
    static int step=0;
    public static void main(String[] args) {
        int n=6;
        move(n,'A','B','C');
        System.out.println("step:"+step);
    }

    private static void move(int n, char a, char temp, char c) {
        if(n==1) {
            System.out.println(a + "->" + c);
            step++;
        }else {
            move(n - 1, a, c, temp);//A->C
            move(1,a,temp,c);//A->B
            move(n - 1, temp, a, c);//C->B
        }
    }

//    public static move
}
